import os, sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from lList import DCLinkList

#Haha, my code is the same as the answer.
def Merge(A, B):
    t = A.dhead.prior
    q = B.dhead.next
    B_t = B.dhead.prior
    t.next = q
    q.prior = t
    A.dhead.prior = B_t
    B_t.next = A.dhead

    
if __name__ ==  "__main__":
    A = DCLinkList()
    A.CreateListR([1,2,3])
    B = DCLinkList()
    B.CreateListR([4,5,6,7])
    Merge(A, B)
    A.display()
